<template>
  <div class="func-comp-form">

    <ComponentGlobalSettingForm :id="id" :compConfigData="compConfigData"></ComponentGlobalSettingForm>

    <Tabs name="main_tabs" size="small" v-model="mainTabsValue">
      <TabPane name="main_tab" tab="main_tabs" label="主配置">
        <Collapse value="0">
          <Panel>
            柱条配置
            <div slot="content">
              <Form :label-width="100">
                <FormItem label="柱条宽度">
                  <InputNumber size="small" :max="1000" :min="1" v-model="chartOption.series[0].barWidth"></InputNumber>
                </FormItem>
                <FormItem label="两侧圆弧效果">
                  <Tooltip content="需要刷新设计器才可以看到此配置后效果，刷新前记得保存页面" max-width="200" placement="left">
                    <i-switch v-model="chartOption.series[0].roundCap">
                      <span slot="open"></span>
                      <span slot="close"></span>
                    </i-switch>
                  </Tooltip>
                </FormItem>
                <FormItemPanel title="渐变色">
                  <FormItem label="起始颜色">
                    <PnColorPicker size="small" v-model="chartOption.series[0].itemStyle.color.startColor" alpha recommend/>
                  </FormItem>
                  <FormItem label="结束颜色">
                    <PnColorPicker size="small" v-model="chartOption.series[0].itemStyle.color.endColor" alpha recommend/>
                  </FormItem>
                </FormItemPanel>
                <FormItem label="阴影大小">
                  <InputNumber size="small" :max="1000" :min="1" v-model="chartOption.series[0].itemStyle.shadowBlur"></InputNumber>
                </FormItem>
                <FormItem label="阴影颜色">
                  <PnColorPicker size="small" v-model="chartOption.series[0].itemStyle.shadowColor" alpha recommend/>
                </FormItem>

                <FormItemPanel title="值标签">
                  <FormItem label="显示">
                    <i-switch v-model="chartOption.series[1].showValue">
                      <span slot="open"></span>
                      <span slot="close"></span>
                    </i-switch>
                  </FormItem>
                  <FormItem label="字体颜色">
                    <PnColorPicker size="small" v-model="chartOption.series[1].style.fill" alpha recommend/>
                  </FormItem>
                  <FormItem label="字体大小">
                    <InputNumber size="small" :max="1000" :min="1" v-model="chartOption.series[1].style.fontSize"></InputNumber>
                  </FormItem>
                </FormItemPanel>

              </Form>
            </div>
          </Panel>
          <Panel>
            轴标签
            <ShowToggle class="float-right" v-model="chartOption.radiusAxis.axisLabel.show"></ShowToggle>
            <div slot="content">
              <Form :label-width="100">
                <FormItem label="标签与轴的间距">
                  <InputNumber size="small" :max="1000" :min="0" v-model="chartOption.radiusAxis.axisLabel.margin"></InputNumber>
                </FormItem>
                <FormItem label="字体颜色">
                  <PnColorPicker size="small" v-model="chartOption.radiusAxis.axisLabel.color" alpha recommend/>
                </FormItem>
                <FormItem label="字体大小">
                  <InputNumber size="small" :max="1000" :min="1" v-model="chartOption.radiusAxis.axisLabel.fontSize"></InputNumber>
                </FormItem>
              </Form>
            </div>
          </Panel>
          <Panel v-if="chartOption.title">
            标题
            <ShowToggle class="float-right" v-model="chartOption.title.show"></ShowToggle>
            <div slot="content">
              <EchartsTitleConfigForm v-model="chartOption.title"></EchartsTitleConfigForm>
            </div>
          </Panel>
          <Panel>
            其他
            <div slot="content">
              <EchartsOtherConfigForm v-model="compConfigData"></EchartsOtherConfigForm>
            </div>
          </Panel>
        </Collapse>
      </TabPane>
      <TabPane name="extend_tab" tab="main_tabs" label="扩展配置">
        <Container v-if="mainTabsValue == 'extend_tab'">
          <CustomOptionDocument :componentId="id"></CustomOptionDocument>
          <CodeEditor v-model="customOption" mode="json"></CodeEditor>
          <EchartsSpreadingCodeForm v-model="echartsSpreadingCode"></EchartsSpreadingCodeForm>
        </Container>
      </TabPane>
      <TabPane name="datasource_tab" tab="main_tabs" label="数据源">
        <DatasourceState v-if="mainTabsValue == 'datasource_tab'" targetComp="CircleBarChart"></DatasourceState>
      </TabPane>
      <TabPane name="interaction_tab" tab="main_tabs" label="交互">
        <Container v-if="mainTabsValue == 'interaction_tab'">
          <InteractionReceive></InteractionReceive>
          <CustomJsDocument></CustomJsDocument>
          <FormItemPanel title="初始化运行脚本">
            <CodeEditor v-model="customGlobalJsCode"></CodeEditor>
          </FormItemPanel>

          <FormItemPanel title="数据项点击时运行">
            <InteractionSender :interactionKey="'itemClick'" :canAddFieldsMap="false"></InteractionSender>
            <Alert style="padding: 5px;">此脚本中，使用_this指向当前组件vm实例，通过params可获取点击项数据</Alert>
            <CodeEditor v-model="dataItemClickJsCode"></CodeEditor>
          </FormItemPanel>
        </Container>
      </TabPane>
    </Tabs>
  </div>
</template>

<script>

  import FuncCompFormMixin from '@/mixin/FuncCompFormMixin'

  import { createHelpers } from 'vuex-map-fields';

  const { mapFields } = createHelpers({
    getterType: 'designer/getLayoutItem',
    mutationType: 'designer/updateLayoutItem',
  });

  export default {
    name: 'CircleBarChartForm',
    mixins: [FuncCompFormMixin],
    data() {
      return {

      }
    },
    mounted() {

    },
    methods: {

    },
    computed: {
      ...mapFields({

        chartOption: 'component.compConfigData.chartOption'

      })
    }
  }
</script>

<style scoped>

</style>
